/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.autoescola.core.entity.questionary;

import com.autoescola.core.entity.Entitie;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author leonardo luz fernandes
 * @version 0.1
 * @since 01/11/2010
 */

@XmlRootElement(name="Question")
@Entitie
@Entity
@Table(name="question")
public class Question implements java.io.Serializable {

    private Long id;
    private String question;
    private List<Category> catogories;
    private Answer answer;


    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    @Column(name="id",nullable=false,unique=true)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getQuestion() {
        return question;
    }

    public void setQuestion(String question) {
        this.question = question;
    }

    @OneToMany(targetEntity=Category.class)
    @JoinTable(name="question_category",joinColumns=@JoinColumn(name="question_id",referencedColumnName="id"),inverseJoinColumns=@JoinColumn(name="category_id",referencedColumnName="id"))
    public List<Category> getCategories(){
        return this.catogories;
    }//end method

    public void setCategories( List<Category> categories ){
        this.catogories = categories ;
    }//end method


    @OneToOne(targetEntity=Answer.class)
    @JoinColumn(table="answer",columnDefinition="answer_id",referencedColumnName="id")
    public Answer getAnswer(){
        return this.answer;
    }//end method

    public void setAnswer( Answer answer ){
        this.answer = answer ;
    }//end method

}//end klazz
